<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script language="javascript">
function updateRecord(id){
    var f=document.form;
    f.method="post";
    f.action='update.jsp?id='+id;
    f.submit();
}

</script>
</head>
<body>
<form method="post" action="" name="form">
<table border="1">
<tr><th>Id</th><th> Name</th><th>Image</th><th>Address</th><th>District</th><th>City</th><th>State</th><th>Zip Code</th><th>Email</th><th>Mobile Number</th><th>Sex</th><th>Course</th><th>Course_fee</th><th>Paid</th></tr>
<%
System.out.println("before get ID");
String id=request.getParameter("id");
int ID=Integer.parseInt(id);
System.out.println("agter change ID into integer");
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/STUDENTS", "root", "sannu");
System.out.println("after connection");
String query = "select * from REGISTRATION where id='"+ID+"'";
System.out.println("after query");
PreparedStatement psmt=connection.prepareStatement(query);
System.out.println("after prepared statement");
ResultSet rs = psmt.executeQuery(query);
while(rs.next()){
%>
<tr>
<td><input type="hidden" name="Id" value="<%=rs.getInt("id")%>"></td>
<td><input type="text" name="name" value="<%=rs.getString("name")%>"></td>
<td><input type="file" name="image" value="<%=rs.getString("image")%>"></td>
<td><input type="text" name="address" value="<%=rs.getString("at")%>"></td>
<td><input type="text" name="district" value="<%=rs.getString("district")%>"></td>
<td><input type="text" name="city" value="<%=rs.getString("city")%>"></td>
<td><input type="text" name="state" value="<%=rs.getString("state")%>"></td>
<td><input type="text" name="zip" value="<%=rs.getString("zip")%>"></td>
<td><input type="text" name="email" value="<%=rs.getString("email")%>"></td>
<td><input type="text" name="mob" value="<%=rs.getString("mob")%>"></td>
<td><input type="text" name="sex" value="<%=rs.getString("sex")%>"></td>
<td><input type="text" name="course" value="<%=rs.getString("course")%>"></td>
<td><input type="text" name="course_fee" value="<%=rs.getString("course_fee")%>"></td>
<td><input type="text" name="paid" value="<%=rs.getString("paid")%>"></td>


</tr>
<tr>
<td><input type="submit" name="Submit" value="Update" style="background-color:#49743D;font-weight:bold;color:#ffffff;"onclick="updateRecord(<%=rs.getString(1)%>);"></td>
</tr>
<%
}
}
catch(Exception e){}
%>
</table>
</form>
</body>
</html>